home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
n_b_v203.zip
/
R&W-BLOK.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
6KB
|
85 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME R&W-BLOK.DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
$endif
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
$INCLUDE "DAS-NB01.INC"
$INCLUDE "DAS-NB02.INC"
COLOR 7,0
CLS
? "┌────────────────────────────────────────────────────────────────────────────
? "│ fWriteBlock? (Handle%,ANY,Bytes??) fReadBlock? (Handle%,ANY,Bytes??)
? "│ fWriteBlockPtr?(Handle%,P???,Bytes??) fReadBlockPtr?(Handle%,P???,Bytes??)
? "├─────────────────────────────────────────────────────────────────────────────
? "│ These do for numeric arrays what fWriteI and fReadI do for numeric variables.
? "│ Now, however, the saving in typing, time and code is much greater as the R/W
? "│ takes place directly from/to memory bypassing PowerBASIC completely.
? "│ The functions on the second line above are the same except that they use
? "│ far-pointers to the data instead of a numeric array element.
? "├─────────────────────────────────────────────────────────────────────────────
? "│ SEE: FSEEK.TXT
? "└─────────────────────────────────────────────────────────────────────────────
'┌────────────────────────
F$ = "DUMMY.DAT" '│ a junk file
DIM Arr%(99) '│
QLoadIarr Arr%(0), 0, 100 '│
'│
OPEN "B", #1, F$ '│ open the file
Handle% = FILEATTR( 1, 2 ) '│ get DOS's file handle
'│
fWriteBlock Handle%, Arr%(0), 200 '│ write 200 bytes to file
REDIM Arr%(99) '│ set array elements = 0
SEEK #1, 0 '│ back to the top
fReadBlock Handle%, Arr%(0), 200 '│ read 200 bytes from file
'│
FOR X% = 0 TO 99 '│ display the 100 elements
PRINT USING "### "; Arr%(X%); '│
NEXT '│
'├─────────────────────────
SEEK #1, 0 '│ time test!
MTIMER '│
fWriteBlock Handle%, Arr%(0), 200 '│ this equals >>─────────┐
DASoft = MTIMER '│ │
'│ │
SEEK #1, 0 '│ │
'│ │
MTIMER '│ │
DEF SEG = VARSEG( Arr%(0) ) '│ <<───┐ all of this! <<─┘
Ptr% = VARPTR( Arr%(0) ) '│ │
Bytes& = 200 '│ │ not to mention
MaxBytes% = 1024 '│ │ the free error
DO '│ │ trapping :-)
B% = MIN( MaxBytes%, Bytes& ) '│ │
DECR Bytes&, B% '│ │
INCR B%, B% '│ │
D$ = PEEK$( Ptr%, B% ) '│ │
PUT$ #1, D$ '│ │
INCR Ptr%, B% '│ │
LOOP UNTIL Btyes& < 1 '│ │
DEF SEG '│ <<───┘
PBasic = MTIMER '│
'│
PRINT '│
PRINT "Elapsed times:" '│
PRINT USING " DASoft#,### m/sec"; DASoft '│
PRINT USING " PBasic#,### m/sec"; PBasic '│
'│
CLOSE #1 '│ close the file
KILL F$ '│ keep your HD clean!
'└─────────────────────────